package isogame
{
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.geom.Matrix;

	public class Tile extends Sprite{		
		
		private var w:Number;
		private var h:Number;
		private var cont:Sprite = new Sprite();
		private var bitmap:BitmapData;
		
		//---------------------------------------
		// CONSTRUCTOR
		//---------------------------------------
		public function Tile(w:Number, h:Number, texture:BitmapData){
			this.w = w;
			this.h = h;
			this.bitmap = texture;
		
			draw();
			
			addChild(cont);
		}
		
		//---------------------------------------
		// GETTER / SETTERS
		//---------------------------------------
		
		
		//---------------------------------------
		// PUBLIC METHODS
		//---------------------------------------
		
		
		//---------------------------------------
		// PRIVATE METHODS
		//---------------------------------------
		
		private function draw():void {
			
			var bitmapData:BitmapData = new BitmapData(bitmap.width, bitmap.height, false);
			bitmapData.draw(bitmap, new Matrix());

			
			cont.graphics.lineStyle(1);
			cont.graphics.beginBitmapFill(bitmapData);
			cont.graphics.moveTo(0 ,-h/2);
			
			cont.graphics.lineTo(w,0);
			cont.graphics.lineTo(0,h/2);
			cont.graphics.lineTo(-w,0);
			cont.graphics.lineTo(0,-h/2);
			
			//cont.graphics.endFill();
			
		}
		
	}// end class
}// end package